<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="viewport" content="height=device-height,width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no" />
<title>好友收到邀请</title>
<link href="img/css/css.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="js/jquery-1.10.1.min.js"></script>
<script type="text/javascript" src="js/QueryStringParser.js"></script>
<script type="text/javascript" src="js/jquery.json.min.js"></script>  
<script type="text/javascript" src="js/jsonMsg.js"></script>  
</head>

<body>
<div class="keep" id="pop" style="display: none;"><img src="img/popup_text.png"></div>
<div class="friend_img" id="friends"><img src="img/friend_pic.png"></div>
<div class="code_info mt10">
      <p>您的好友 <font id="nickname"></font> 邀请您加入公众号--结伴旅行。同行的还有高帅富、白富美，您还在等什么呢。</p>
</div>
<div class="bottom_btn">
     <div class="left_btn"><p class="ico_group"><a href="javascript:void(0);" onclick="closePage()"><i class="iconfont img">&#xe601;</i>拒绝</a></p></div>
     <div class="right_btn line_left"><p class="ico_group" onclick="joins()" style="cursor:pointer;"><i class="iconfont img">&#xe602;</i>接受</p></div>
</div>
</body>
</html>

<script type="text/javascript">
function closePage(){
		if (navigator.userAgent.indexOf("MSIE") > 0) {
		  if (navigator.userAgent.indexOf("MSIE 6.0") > 0) {
		   window.opener = null;
		   window.close();
		  } else {
		   window.open('', '_top');
		   window.top.close();
		  }
		 }
		 else if (navigator.userAgent.indexOf("Firefox") > 0) {
		  window.location.href = 'about:blank ';
		 } else {
		  window.opener = null;
		  window.open('', '_self', '');
		  window.close();
		 }
}

var inviteUser = queryString.getParam("inviteUser");
var acceptUser = queryString.getParam("acceptUser");
function joins(){
	var members = [];
	members.push(acceptUser);
	var dataStr = {   
        OpenIDs:members,
        Type: 1,
        ID:0
    };  
	
	
	var bodyStr = popBody('InviteFriend',dataStr);
	var request = popRequest('InviteFriend',inviteUser,bodyStr);
	//调用了jquery.json 库  
	var encoded = $.toJSON( request );  
	var jsonStr = encoded;  
	
	$.ajax({  
	url : actionStr,  
	type : 'POST',  
	data : jsonStr,  
	dataType : 'json',  
	contentType : 'application/json',  
	success : function(data, status, xhr) {  
		//Do Anything After get Return data  
		var dataStr = {
			OpenID: 	acceptUser
		};	
		var bodyStr = popBody('UserDetail',dataStr);
		var request = popRequest('UserDetail',acceptUser,bodyStr);
		//调用了jquery.json 库  
		var encoded = $.toJSON( request );  
		var jsonStr = encoded;  

		$.ajax({  
		url : actionStr,  
		type : 'POST',  
		data : jsonStr,  
		dataType : 'json',  
		contentType : 'application/json',  
		success : function(data, status, xhr) {  
		//         Do Anything After get Return data  
				if(data.portalResp.Data.Profiles.status=='0'){
					//说明还没有关注公众号
					document.getElementById("pop").style.display="";
				}else{
					window.location.href="friend_list.html?openid="+acceptUser;	
				}
		},  
		Error : function(xhr, error, exception) {  
		    // handle the error.    
		    alert(exception.toString());  
		}  
		});  
	},  
	Error : function(xhr, error, exception) {  
	    // handle the error.    
	    alert(exception.toString());  
	}  
	});  
}
$(document).ready(function(){
  	
	if(inviteUser==null || inviteUser==""){
		return false;	
	}else{
		var dataStr = {
			OpenID: 	inviteUser
		};	
		var bodyStr = popBody('UserDetail',dataStr);
		var request = popRequest('UserDetail',inviteUser,bodyStr);
		//调用了jquery.json 库  
		var encoded = $.toJSON( request );  
		var jsonStr = encoded;  

		$.ajax({  
		url : actionStr,  
		type : 'POST',  
		data : jsonStr,  
		dataType : 'json',  
		contentType : 'application/json',  
		success : function(data, status, xhr) {  
		//         Do Anything After get Return data  
		        $("#friends").html("");	
						var imageURL = data.portalResp.Data.Profiles.ImageURL;
//						if(imageURL.substring(imageURL.length-3)=="/64"){
//          			imageURL = imageURL.substring(0,imageURL.length-3)+"/132";
//          	}
						$("#friends").html("<img src='"+imageURL+"'>");	 
						$("#nickname").html(data.portalResp.Data.Profiles.NickName);	
		},  
		Error : function(xhr, error, exception) {  
		    // handle the error.    
		    alert(exception.toString());  
		}  
		});  
	}
	
});

</script>